package org.htmlparser.parserapplications;

import java.io.PrintStream;
import javax.swing.JOptionPane;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;

public class LinkExtractor
{
  static Class class$org$htmlparser$tags$LinkTag;

  static Class class$(String paramString)
  {
    Class localClass;
    try
    {
      localClass = Class.forName(paramString);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError().initCause(localClassNotFoundException);
    }
  }

  public static void main(String[] paramArrayOfString)
  {
    String str1;
    Class localClass;
    NodeClassFilter localNodeClassFilter;
    Object localObject;
    String str2;
    if (paramArrayOfString.length <= 0)
    {
      str2 = (String)JOptionPane.showInputDialog(null, "Enter the URL to extract links from:", "Web Site", -1, null, null, "http://htmlparser.sourceforge.net/wiki/");
      if (str2 != null)
        break label179;
      System.exit(1);
      str1 = str2;
      if (class$org$htmlparser$tags$LinkTag != null)
        break label154;
      localClass = class$("org.htmlparser.tags.LinkTag");
      class$org$htmlparser$tags$LinkTag = localClass;
      localNodeClassFilter = new NodeClassFilter(localClass);
      if ((1 >= paramArrayOfString.length) || (!(paramArrayOfString[1].equalsIgnoreCase("-maillinks"))))
        break label173;
      localObject = new AndFilter(localNodeClassFilter, new 1());
    }
    try
    {
      while (true)
      {
        NodeList localNodeList = new Parser(str1).extractAllNodesThatMatch((NodeFilter)localObject);
        int i = 0;
        while (true)
        {
          if (i >= localNodeList.size())
            break label168;
          System.out.println(localNodeList.elementAt(i).toHtml());
          ++i;
        }
        str1 = paramArrayOfString[0];
      }
      label154: label168: label173: label179: localClass = class$org$htmlparser$tags$LinkTag;
    }
    catch (ParserException localParserException)
    {
      while (true)
      {
        while (true)
        {
          localParserException.printStackTrace();
          System.exit(0);
          return;
          localObject = localNodeClassFilter;
        }
        str1 = str2;
      }
    }
  }
}